package com.ssm.security;

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;

/**
 * 生成自定义认证 token
 * 目标使用自己的jwt
 * 注意：remember_me中的凭证也要记得使用这种方法
 * 注意：JWT不是基于cookie的，所以要摸索出不适用cookie的思路
 */
public class SignedUsernamePasswordAuthenticationToken extends UsernamePasswordAuthenticationToken {
    private String requestSignature;

    /**
     * For serialization.
     */
    private static final long serialVersionUID = 3145548673810647886L;

    /**
     * Construct a new token instance with the given principal, credentials, and signature.
     *
     * @param principal the principal to use
     * @param credentials the credentials to use
     * @param signature the signature to use
     */
    public SignedUsernamePasswordAuthenticationToken(String principal,String credentials, String signature) {

        super(principal, credentials);
        this.requestSignature = signature;
    }

    /**
     * @param requestSignature the requestSignature to set
     */
    public void setRequestSignature(String requestSignature) {
        this.requestSignature = requestSignature;
    }

    /**
     * @return the requestSignature
     */
    public String getRequestSignature() {
        return requestSignature;
    }
}
